import com.TanNgee.HelloService;
import com.TanNgee.annotation.RpcScan;
import com.TanNgee.config.RpcServiceConfig;
import com.TanNgee.remoting.transport.netty.server.NettyRpcServer;
import com.TanNgee.serviceimpl.HelloServiceImpl2;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author 陈毅
 * @create 2022/3/23 15:55
 */

@RpcScan(basePackage = {"com.TanNgee"})

public class NettyServerMain {
    public static void main(String[] args) {
        // 通过注释 注册服务
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(NettyServerMain.class);

        NettyRpcServer nettyRpcServer = (NettyRpcServer) applicationContext.getBean("nettyRpcServer");


        HelloService helloService2 = new HelloServiceImpl2();

        // @lomlock
        RpcServiceConfig rpcServiceConfig = RpcServiceConfig.builder()
                .group("test2").version("version2").service(helloService2).build();

        //手动注册服务
        nettyRpcServer.registerService(rpcServiceConfig);

        nettyRpcServer.start();
    }
}
